﻿using System;
using System.Collections.Generic;
using System.Text;
using RegionInterface;
using UnityEngine;
using Common;

public partial class GUIModule : INetwork , IGUIModule
{
    public void SendChat(ChatType type, string name, string text)
    {
        AppInterface.NetworkModule.SendNetworkMessage(ServerType.RegionServer, delegate(DataObject msg)
        {
            switch (type)
            {
                case ChatType.Region:
                    {
                        msg.WriteByte(GameMessageType.REGION_CHAT);
                        break;
                    }
            }
            msg.WriteInt32(AppInterface.AvatarModule.IOwner.Id);
            msg.WriteString(name);
            msg.WriteString(text);
        });
    }
    #region IGUIModule Members
    public event ScreenChangeHandle OnScreenChange;
    private void screenChange(int width, int height)
    {
        if (OnScreenChange != null) OnScreenChange(width, height);
    }
    public void ShowScore(Transform transform, int score)
    {
        Score.ShowScore(transform, score);
    }
    private float defaultHeight = 600; 
    public float DefaultHeight
    {
        get { return defaultHeight; }
    }
    private float defaultWidth = 1000;
    public float DefaultWidth
    {
        get { return defaultWidth; }
    }
    private float heightScale = 0;
    public float HeightScale
    {
        get { return heightScale; }
    }
    private int screenHeight = 600;
    public int ScreenHeight
    {
        get { return screenHeight; }
    }
    private int screenWidth = 1000;
    public int ScreenWidth
    {
        get { return screenWidth; }
    }
    private float widthScale = 0;
    public float WidthScale
    {
        get { return widthScale; }
    }
    #endregion

    #region INetwork Members
    public ModuleType Type
    {
        get { return ModuleType.GUI; }
    }
    public void OnNetMessage(ServerType type, DataObject msg)
    {
        if (type == ServerType.RegionServer)
        {
            switch (msg.ReadByte())
            {
                case GameMessageType.REGION_CHAT:
                    {
                        msg.ReadInt32();
                        Chat.Chat(ChatType.Region, msg.ReadString(), msg.ReadString());
                        break;
                    }
            }
        }
    }
    #endregion
}
